<template>
	<view >
		<!-- <scroll-view scroll-x class="bg-white nav " >
			<view class='flex text-center'>
				<view class="cu-item flex-sub text-df " @click="navselect(index)" v-for="(nav,index) in navlist" :key="index"
				 :class="[index == currentIndex ? 'text-red cur' : '']">
					{{nav}}
				</view>
			</view>
		</scroll-view> -->
		
		<view >
			<view v-for="(orderdetail,index) in order_list" :key="index">
				<view class="bg-white margin-sm padding-sm solids-bottom shadow radius text-content" @click="goDetail(orderdetail)">
					<!-- 表头 -->
					<view class="flex justify-between"> 
						<view class="text-bold" style="flex-shrink: 0;">
							<text class="text-red">{{ orderdetail.status == '0'?'待审核':'' }}</text>
							<text class="text-green">{{ orderdetail.status == '1'?'审核通过':'' }}</text>
							<!-- <text class="text-red">{{ orderdetail.status == '2'?'审核中':'' }}</text>
							<text class="text-blue">{{ orderdetail.status == '3'?'审核完成':'' }}</text>
							<text class="text-grey">{{ orderdetail.status == '4'?'审核未通过':'' }}</text> -->
						</view>
						<view ><text class="text-bold solids-bottom">{{ orderdetail.datatime }}</text></view>
					</view>

					<view >
						<view class="bg-white margin-xs padding-xs shadow radius text-content"
						 v-for="(item,index) in orderdetail.attach" :key="index">
							<view class="flex padding-top-sm solids-top">
								<image :src="item.path" v-if="item.type=='img'" style="flex-shrink: 0;" mode="aspectFill" class="shadow cover radius solids"></image>
								<image src="../../../static/img/gongLog.png" v-if="item.type=='other'"  style="flex-shrink: 0;" mode="aspectFill" class="shadow cover radius solids"></image>
								<view class="flex text-content padding-left justify-between" style="flex-grow: 1;">
									<view>{{ item.name }}</view>
									<view style="flex-shrink: 0;">
										<!-- <view>￥{{ item.sell_price/100 }}</view>
										<view class="text-grey text-center">×{{item.num}}</view> -->
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="flex justify-end" style="font-size: 24upx;">
						<!-- <button @click.stop="kefu" class="round lines-grey cu-btn shadow mid margin-right-sm">查看</button> -->
						<view v-if="orderdetail.status == '0'">
							<view class="round cu-btn lines-grey mid shadow margin-right-sm" @click.stop="cancel(index)">通过</view>
							<view class=" round cu-btn lines-orange mid shadow" @click.stop="goDetail33(orderdetail)">不通过</view>
						</view>
					</view>
				</view>
			</view>
			<!-- <view style="margin-bottom: 50upx;">
				<uni-pagination :total="total[currentIndex]" pageSize="10" :current="pages" @change="paginat">
				</uni-pagination>
			</view> -->
		</view>
	</view>
</template>

<script>
	import uniPagination from "@/components/uni-pagination/uni-pagination.vue"
	let _this;
	export default {
		components:{uniPagination},
		data() {
			return {
				navlist: [
					'待审核', '审核结束'
				],
				currentIndex: 0,
				superInfo:{},
				pages: 1,
				order_list: [
					/* {
						"datatime":"2020-2-22",
						"status": "1",
						"attach": {
							"3": {
								"book_name": "塔吊租赁合同.xlsx",
								"cover_image": "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=4099049007,543588798&fm=26&gp=0.jpg"
							},
							"5": {
								"book_name": "塔吊租赁合同2.xlsx",
								"cover_image": "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=4099049007,543588798&fm=26&gp=0.jpg"
							}
						}
						
					} */
				]
				
			}
		},
		
		onLoad(option){
			_this=this;
			console.log( JSON.parse(option.pointInfo));
			this.superInfo= JSON.parse(option.pointInfo);
			this.getListData();
		},
		methods: {
           navselect:function(index){
			   _this.currentIndex=index;
		   },
		   goDetail:function(info){
			   console.log(info)
		   },
		   /* 获取列表数据 */
		   getListData() {
		   	let list = [];			
		   	const value = uni.getStorageSync("JSESSIONID");
		   	const val = uni.getStorageSync("pathHost");
		   	uni.request({
		   		url: val+"/ggcapp/infoupload/infoupload/ggInfoUpload/data"+";JSESSIONID="+value+"?__ajax=true&mobileLogin=true&pageSize=9999&pointId="+_this.superInfo.id+"&projectId="+_this.superInfo.projectId,
		   		success(date) {
		   			 for (var i = 0; i < date.data.rows.length; i++) {
						 let attachs=[]
						 let files=date.data.rows[i].filePath.split('|');
						// console.log(files)
						 for (var j = 0; j < files.length; j++) {
							let type = files[j].substring(files[j].lastIndexOf('.')+1);
							if(type=="jpg" || type=="png"  || type=="jpeg"){
								type="img"
							}else{
								type="other"
							}
						 	attachs.push({
								type:type,
								path:val+""+files[j],
								name:files[j].substring(files[j].lastIndexOf('/')+1)	
							})
							//console.log(attachs)
						 } 
		   			 	list.push({
							id:date.data.rows[i].id,
							pointId:date.data.rows[i].pointId,
							projectId:date.data.rows[i].projectId,
		   					status:date.data.rows[i].state,
		   					datatime:date.data.rows[i].createDate,
							attach:attachs
		   				})
		   			 } 
		   			
		   			//console.log(list)
					_this.order_list=list;
		   			
		   		}
		   	});
		   		
		   	_this.userList = list; 
		   },
		   goDetail33:function(info){
		   			   	console.log("不通过"+info)
		   				console.log(info)
		   },
		   cancel(index){
			  	console.log("通过"+index)
		   }
		}
	}
</script>

<style>
	.cover {
		width: 150upx;
		height: 150upx;
	}

</style>
